/*
 * Copyright 2020 赖柄沣 bingfengdev@aliyun.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package pers.lbf.yeju.consumer.message.group.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.lbf.yeju.common.core.exception.service.ServiceException;
import pers.lbf.yeju.common.core.result.IResult;
import pers.lbf.yeju.service.interfaces.message.IMessageGroupService;
import pers.lbf.yeju.service.interfaces.message.pojo.SystemMessageGroupInfoBean;
import reactor.core.publisher.Mono;

import java.util.List;

/**
 * TODO
 *
 * @author 赖柄沣 bingfengdev@aliyun.com
 * @version 1.0
 * @date 2021/3/6 14:06
 */
@RestController
@RequestMapping("/message/group")
@Slf4j
@Api(tags = "消息组接口")
public class MessageGroupController {

    @DubboReference
    private IMessageGroupService messageGroupService;


    /**
     * 获取系统消息组
     *
     * @return reactor.core.publisher.Mono<pers.lbf.yeju.common.core.result.IResult < java.util.List < pers.lbf.yeju.service.interfaces.message.pojo.SystemMessageGroupInfoBean>>>
     * @author 赖柄沣 bingfengdev@aliyun.com
     * @version 1.0
     * @date 2021/3/6 14:12
     */
    @ApiOperation(value = "获取系统消息组", notes = "系统消息组说明", httpMethod = "GET")
    @GetMapping("/nameAndId")
    public Mono<IResult<List<SystemMessageGroupInfoBean>>> getSystemMessageGroupNameAndId() throws ServiceException {

        return Mono.just(messageGroupService.findAllSystemMessageGroupAndId());
    }

}
